package com.zjb.demo.system.domain;

import com.mybatisflex.annotation.*;
import com.mybatisflex.core.keygen.KeyGenerators;
import com.zjb.demo.common.domain.dto.BaseEntity;
import com.zjb.demo.common.listener.BaseOnListener;

import java.util.Date;
import java.util.List;

/**
 * @author 庄佳彬
 * @since 2023/12/22 11:17
 */
@Table(value = "sys_user", onInsert = BaseOnListener.class, onUpdate = BaseOnListener.class)
public class User extends BaseEntity {

    /**
     * 用户ID
     */
    @Id(keyType = KeyType.Generator, value = KeyGenerators.flexId)
    @Column(value = "user_id")
    private Long id;
    /**
     * 昵称
     */
    @Column(value = "nick_name")
    private String nickName;
    /**
     * 性别
     */
    @Column(value = "sex")
    private int sex;
    /**
     * 密码
     */
    @Column(value = "password")
    private transient String password;

    /**
     * 用户名
     */
    @Column(value = "user_name")
    private String userName;

    /**
     * 部门ID
     */
    @Column(value = "dept_id")
    private Long deptId;

    /**
     * 登录IP
     */
    @Column(value = "login_ip")
    private String loginIp;

    /**
     * 登录时间
     */
    @Column(value = "login_date")
    private Date loginDate;

    /**
     * 电话号码
     */
    @Column(value = "phonenumber")
    private String phoneNumber;

    /**
     * 邮箱
     */
    @Column(value = "email")
    private String email;

    /**
     * 头像
     */
    @Column(value = "avatar")
    private String avatar;

    @Column(value = "status")
    private String status;


    /**
     * 角色列表
     */
    @RelationManyToMany(joinTable = "sys_user_role",
            selfField = "id",
            joinSelfColumn = "user_id",
            targetField = "roleId",
            joinTargetColumn = "role_id")
    private List<SysRole> roles;

    @RelationOneToOne(
            selfField = "deptId",
            targetField = "deptId")
    private SysDept dept;

    /**
     * 岗位列表
     */
    @Column(ignore = true)
    private List<Long> postIds;
    /**
     * 角色列表
     */
    @Column(ignore = true)
    private List<Long> roleIds;

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public int getSex() {
        return sex;
    }

    public void setSex(int sex) {
        this.sex = sex;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public Long getDeptId() {
        return deptId;
    }

    public void setDeptId(Long deptId) {
        this.deptId = deptId;
    }

    public List<SysRole> getRoles() {
        return roles;
    }

    public void setRoles(List<SysRole> roles) {
        this.roles = roles;
    }

    public String getLoginIp() {
        return loginIp;
    }

    public void setLoginIp(String loginIp) {
        this.loginIp = loginIp;
    }

    public Date getLoginDate() {
        return loginDate;
    }

    public void setLoginDate(Date loginDate) {
        this.loginDate = loginDate;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public SysDept getDept() {
        return dept;
    }

    public void setDept(SysDept dept) {
        this.dept = dept;
    }

    public List<Long> getPostIds() {
        return postIds;
    }

    public void setPostIds(List<Long> postIds) {
        this.postIds = postIds;
    }

    public List<Long> getRoleIds() {
        return roleIds;
    }

    public void setRoleIds(List<Long> roleIds) {
        this.roleIds = roleIds;
    }
}
